package cn.iocoder.yudao.module.dify.service.riskManagementReport;

import cn.iocoder.yudao.module.dify.api.vo.resp.DifyChatFlowUploadResponse;
import cn.iocoder.yudao.module.dify.api.vo.resp.ResponseData;
import cn.iocoder.yudao.module.dify.controller.admin.riskreportrecords.vo.RiskReportRecordsSaveReqVO;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.multipart.MultipartFile;
import reactor.core.publisher.Flux;

import java.io.IOException;
import java.util.List;

/**
 * Dify风险管理报告  Service 接口
 *
 * @author 芋道源码
 */
public interface ChatFlowService {

    /**
     * Dify文件上传
     *
     * @param difyApiKey
     * @param file
     * @param userId
     * @return
     * @throws IOException
     */
    DifyChatFlowUploadResponse chatFlowUploadFile(String difyApiKey, MultipartFile file, Long userId) throws IOException;

    /**
     * Dify风险管理报告-测试分离
     *
     * @param difyChatFlowUploadResponse
     * @param query
     * @param userId
     * @param difyApiKey
     * @return
     * @throws IOException
     */
    @Async
    Flux<ResponseData> getDifyRiskManagementReport(DifyChatFlowUploadResponse difyChatFlowUploadResponse, String query, Long userId, String difyApiKey) throws IOException;

    /**
     * Dify风险管理报告-测试分离--blocking
     * blocking 阻塞模式，等待执行完毕后返回结果。
     *
     * @param difyChatFlowUploadResponse
     * @param query
     * @param userId
     * @param difyApiKey
     * @return
     * @throws IOException
     */
    @Async
    ResponseData getDifyRiskManagementReportBlocking(DifyChatFlowUploadResponse difyChatFlowUploadResponse, String query, Long userId, String difyApiKey) throws IOException;

    /**
     * 异步执行生成风险管理报告
     *
     * @param difyChatFlowUploadResponse
     * @param query
     * @param userId
     * @param difyApiKey
     * @throws IOException
     */
    @Async
    Boolean executeGenerationRiskManagementReport(DifyChatFlowUploadResponse difyChatFlowUploadResponse, String query, Long userId, String difyApiKey) throws Exception;

    /**
     * 异步执行启动任务
     *
     * @param userId
     * @param difyApiKey
     * @throws IOException
     */
    @Async
    Boolean riskManagementReportPerformTasks(Long id, Long userId, String difyApiKey) throws Exception;

    /**
     * 异步执行生成风险管理报告-阻塞模式
     *
     * @param difyChatFlowUploadResponse
     * @param query
     * @param userId
     * @param difyApiKey
     * @throws IOException
     */
    @Async
    Boolean executeGenerationRiskManagementReportBlocking(DifyChatFlowUploadResponse difyChatFlowUploadResponse, String query, Long userId, String difyApiKey) throws Exception;

    @Async
    Boolean riskManagementReportRetry(Long id, Long userId, String difyApiKey) throws Exception;

}
